package com.tony.utils;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

/**
 * @Auther: tony
 * @Date: 2018-11-30 17:08
 * @Description: https://console.faceplusplus.com.cn/documents/7776484
 */
public class FaceAIUtil {

    private static final String API_KEY="B-vzSp9rO8-64i4xRHadIsajn3JtYEaj";
    private static final String API_SECRET="ziH-baz2wBeGbyBwMD5uUYDQc6c96b_N";



    private static final String RecognizeText_Url="https://api-cn.faceplusplus.com/imagepp/v1/recognizetext";




    public static void main(String[] args){
        recognizeText("E:\\test\\test\\1.jpg");
    }

    public static void recognizeText(String str){
        Map<String,String> headerMap=new HashMap<>();
        headerMap.put("Content-Type","application/x-www-form-urlencoded");
        //headerMap.put("User-Agent","okhttp/3.10.0");
        //headerMap.put("Accept-Encoding","gzip");

        //String imageBase64 = Base64.encodeToString(FileHelper.getBytesFromFile(new File(str)), 2);

        String image_url="https://lbdatacenter.oss-cn-zhangjiakou.aliyuncs.com/test/1.jpg";
        String params="api_key="+API_KEY+"&api_secret="+API_SECRET+"&image_url="+image_url;
        String result=HttpUtil.getInstance(false,false).sendPost(RecognizeText_Url,headerMap,params);
        System.out.println(result);
    }

}
